package decisionalalgorithms.guialgorithms.converters;

import com.sun.istack.Nullable;
import decisionalalgorithms.guialgorithms.commands.MatrixBuildDetailsCommand;
import decisionalalgorithms.guialgorithms.domain.MatrixBuildDetails;
import lombok.Synchronized;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class MatrixBuildDetailsCommandToMatrixBuildDetails implements Converter<MatrixBuildDetailsCommand, MatrixBuildDetails> {
    @Synchronized
    @Nullable
    @Override
    public MatrixBuildDetails convert(MatrixBuildDetailsCommand source) {
        if (source == null){
            return null;
        }
        final MatrixBuildDetails matrixBuildDetails = new MatrixBuildDetails();
        matrixBuildDetails.setId(source.getId());
        matrixBuildDetails.setAlpha(source.getAlpha());
        matrixBuildDetails.setNumberOfColumns(source.getNumberOfColumns());
        matrixBuildDetails.setNumberOfRows(source.getNumberOfRows());
        matrixBuildDetails.setPriority(source.getPriority());
        return matrixBuildDetails;
    }
}
